<template>
  <div class="app-container">
    {{$t('recommend.Recommendation_setting')}}
    <div class="filter-container" style="overflow:hidden">
      {{$t('recommend.Sharing_to_recevie_coupon')}}：
      <el-input-number style="margin-left:16px" v-model="givePrice" :min="1"  :label="$t('recommend.Descriptive_text')"></el-input-number>
      {{$t('recommend.yuan')}},
      {{$t('recommend.Validity_period')}}
      <el-input-number v-model="giveTime" :min="1"  :label="$t('recommend.Descriptive_text')"></el-input-number> 
      {{$t('recommend.day')}}
    </div>
    <div class="filter-container" style="overflow:hidden">
      {{$t('recommend.Referral_reveices_coupon')}}：
      <el-input-number v-model="getPrice" :min="1"  :label="$t('recommend.Descriptive_text')"></el-input-number>
      {{$t('recommend.yuan')}},
      {{$t('recommend.Validity_period')}}
      <el-input-number v-model="getTime" :min="1"  :label="$t('recommend.Descriptive_text')"></el-input-number>
      {{$t('recommend.day')}}
    </div>
    <el-button @click="updataParameter" type="primary" style="margin-top:50px;margin-left:10px;width:100px">{{$t('recommend.save')}}</el-button>
  </div>
</template>

<script>
import { updateSystemParamter , getSystemParamter } from '@/api/system'
import { validatePhone } from '@/utils/validate'
export default {
  name: 'recommend_setting',
  data(){
    return{
      giveTime:'',
      givePrice:'',
      getTime:'',
      getPrice:'',
    }
  },
  methods:{
    //推荐人金额
    async getGivePrice(){
      const{ data } = await getSystemParamter({
        key:'SYS00009',
      })
      this.givePrice = data.systemValue
    },
    async setGivePrice(){
      const { data } = await updateSystemParamter({
        key:'SYS00009',
        value:this.givePrice
      })
    },
    //推荐人期限
    async getGiveTime(){
      const{ data } = await getSystemParamter({
        key:'SYS00010',
      })
      this.giveTime = data.systemValue
    },
    async setGiveTime(){
      const { data } = await updateSystemParamter({
        key:'SYS00010',
        value:this.giveTime
      })
    },
    //被推荐人金额
    async getGetPrice(){
      const{ data } = await getSystemParamter({
        key:'SYS00011',
      })
      this.getPrice = data.systemValue
    },
    async setGetPrice(){
      const { data } = await updateSystemParamter({
        key:'SYS00011',
        value:this.getPrice
      })
    },
    //被推荐人期限
    async getGetTime(){
      const{ data } = await getSystemParamter({
        key:'SYS00012',
      })
      this.getTime = data.systemValue
    },
    async setGetTime(){
      const { data } = await updateSystemParamter({
        key:'SYS00012',
        value:this.getTime
      })
    },
    //总合获取
    getParameter(){
      this.getGetTime()
      this.getGetPrice()
      this.getGivePrice()
      this.getGiveTime()
    },
    //总合修改
    updataParameter(){
      if(!this.giveTime || !this.givePrice ||!this.getTime ||!this.getPrice)
      {
        this.$message({
          type:'error',
          message:this.$t('recommend.the_content_can_not_be_blank')
        });
        return
      }
      Promise.all([this.setGetTime(), this.setGetPrice(), this.setGivePrice(), this.setGiveTime()])
      .then(() => {
        this.$message({
          type: 'success',
          message: this.$t('recommend.Successfully_modified')
        });
        this.getParameter()
      })
      
      
      
      
    
    }
  },
  created(){
    this.getParameter()
  }
}
</script>

<style>
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0;
}
</style>
